<div class="clearfix">
</div>
<div class="grid_3 grid_4">
    <div class="page-header">
        <h4>密码修改</h4>
    </div>
    <div class="bs-example">
            <table class="table">
                <tbody>
                <tr>
                    <td style="width: 120px;"><h5 style="margin: 5px;">旧密码：<a class="anchorjs-link" href=""><span
                            class="anchorjs-icon"></span></a></h5></td>
                    <td>
                        <input type="password" id="OldPsw">
                    </td>
                </tr>
                <tr>
                    <td style="width: 120px;"><h5 style="margin: 5px;">新密码：<a class="anchorjs-link" href=""><span
                            class="anchorjs-icon"></span></a></h5></td>
                    <td>
                        <input type="password" id="NewPsw">
                    </td>
                </tr>
                <tr>
                    <td style="width: 120px;"><h5 style="margin: 5px;">确认新密码：<a class="anchorjs-link" href=""><span
                            class="anchorjs-icon"></span></a></h5></td>
                    <td>
                        <input type="password" id="NewPsw-confirm">
                    </td>
                </tr>
                </tbody>
            </table>
        <div>
            <button id="updatepsw-btn" class="btn btn-primary">保存</button>
        </div>
    </div>
</div>
<script>
    $(function () {
        $('#updatepsw-btn').click(function () {
            var OldPsw = $("#OldPsw").val();
            var NewPsw = $("#NewPsw").val();
            var NewPswConfirm = $("#NewPsw-confirm").val();
            if (NewPsw === NewPswConfirm) {
                $.ajax({
                    type: "POST",
                    url: "/user/UpdatePsw.post",
                    data: {
                        id : ${hrmUser.id},
                        OldPsw : OldPsw,
                        NewPsw : NewPsw
                    },
                    success: function (data) {
                        var result = data;
                        if (result === 1) {
                            alert("修改密码成功！");
                        } else {
                            alert(data);
                        }
                    },
                    error: function () {
                        alert('保存出现异常');
                    }
                })
            } else {
                alert("两次输入的新密码不同，请重试");
            }
        })
    })
</script>